﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RPGXEngine
{
    public class AssignmentCommand_IsGreaterThanOrEqual : IAssignmentCommand
    {
        #region IAssignmentCommand Members

        public ICommand Left { get; set; }
        public ICommand Right { get; set; }

        #endregion

        #region ICommand Members

        public bool IsReturn { get { return false; } }
        public bool IsIf { get { return false; } }

        public List<ICommand> ChildrenCommands
        {
            get
            {
                return null;
            }
        }

        public IVariableType Execute(ScriptManager sm, FunctionScope scope)
        {
            IVariableType v1 = this.Left.Execute(sm, scope);
            IVariableType v2 = this.Right.Execute(sm, scope);

            int i = ((IComparable)v1.Value).CompareTo(v2.Value); // TODO make a CompareTo method in IVariableType
            bool b = i == 0 || i > 0;

            return VariableTypeFactory.Create(DataType.Var, String.Empty, b);
        }

        #endregion
    }
}
